﻿#coding=utf-8
from django.db import models

# Create your models here.
class NewsType(models.Model):
    type = models.CharField('新闻类型', max_length=50)
    
    def __unicode__(self):
        return self.type
    
    class Meta:
        verbose_name_plural = '新闻类型'

class News(models.Model):
    title = models.CharField('标题', max_length=50)
    pub_date = models.DateTimeField("发布日期",auto_now=True)
    content = models.TextField('内容',max_length=800)
    is_notify = models.BooleanField('是否通知')
    news_type = models.ForeignKey(NewsType, verbose_name='新闻类型')
    
    def __unicode__(self):
        return self.title

    class Meta:
        verbose_name_plural = '新闻'
        ordering = ['-pub_date']
        
    def get_absolute_url(self):
        return "/news/detail/%i/" % self.id

class GuestBookType(models.Model):
    type = models.CharField('留言类型', max_length=50)
    
    def __unicode__(self):
        return self.type

    class Meta:
        verbose_name_plural = '留言类型'

class GuestBookItem(models.Model):
    name = models.CharField('姓名', max_length=50)
    contact = models.CharField('联系方式', max_length=100)
    msg = models.TextField('留言内容',max_length=800)
    msg_type = models.ForeignKey(GuestBookType, verbose_name='留言类型')
    
    def __unicode__(self):
        return self.msg
    
    class Meta:
        verbose_name_plural = '留言'

class PhotoCategory(models.Model):
    type = models.CharField('画册分类', max_length=50)
    
    
    def __unicode__(self):
        return self.type

    class Meta:
        verbose_name_plural = '画册分类'

class PhotoGallery(models.Model):
    img = models.FileField("图片",upload_to='photos/%Y/%m/%d', blank=True)
    desc = models.TextField('描述',max_length=800)
    photo_type = models.ForeignKey(PhotoCategory, verbose_name='画册分类')
    
    def __unicode__(self):
        return self.desc
    
    class Meta:
        verbose_name_plural = '画册'

class PhotoMetaInfo(models.Model):
    photo_id = models.ForeignKey(PhotoGallery)
    height = models.IntegerField(default=0)
    width = models.IntegerField(default=0)

    
class SignUp(models.Model):
    name = models.CharField('姓名', max_length=50)
    org = models.CharField('单位', max_length=50, help_text='备注：学校名、企业名或个人')
    phone = models.CharField('电话', max_length=50)
    email = models.EmailField()
    remark = models.TextField('备注',max_length=800)
    
    def __unicode__(self):
        return self.name
   
    class Meta:
        verbose_name_plural = '在线报名'
        
    def get_absolute_url(self):
        return "/signup/%i/" % self.id

